<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#x00A0;">
]>
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:msxml="urn:schemas-microsoft-com:xslt"
	xmlns:umbraco.library="urn:umbraco.library"
  xmlns:BlogLibrary="urn:BlogLibrary"
  xmlns:Blog="urn:Blog"
	exclude-result-prefixes="msxml umbraco.library BlogLibrary Blog">

  <xsl:output method="html" omit-xml-declaration="yes"/>

  <xsl:param name="currentPage"/>
  <xsl:variable name="numberOfComments" select="10"/>
  <xsl:variable name="currentBlog" select="Blog:XmlCurrent(number($currentPage/@id))" />
  <xsl:variable name="comments" select="$currentBlog//Comment" />

  <xsl:template match="/">

    <xsl:if test="count($comments) &gt; 0">
      <ul>
        <xsl:for-each select="$comments">
          <xsl:sort select="@createdDate" order="descending" />
          <xsl:if test="position() &lt; $numberOfComments +1">
            <xsl:variable name="post" select="./ancestor::* [@isDoc and BlogLibrary:IsType('BlogPost', @id)]"/>
            <li class="comment-item">
              <xsl:value-of select="$post/text()"/>
              <a href="{umbraco.library:NiceUrl($post/@id)}#comment-{./@id}">
                <xsl:value-of select="./@nodeName" /> on <span class="post">
                  <xsl:value-of select="$post/@nodeName" />
                </span>
              </a>
            </li>
          </xsl:if>
        </xsl:for-each>
      </ul>
    </xsl:if>

  </xsl:template>

</xsl:stylesheet>